package com.jcode222.service.impl;

import com.jcode222.dao.IStorageDao;
import com.jcode222.entity.Order;
import com.jcode222.entity.Storage;
import org.springframework.stereotype.Service;
import com.jcode222.service.IStorageService;

import java.util.List;

@Service
public class StorageDoServiceImpl implements IStorageService {

    /**
     * storageDao.
     */
    private final IStorageDao storageDao;

    /**
     * init.
     *
     * @param storageDao role dao
     */
    public StorageDoServiceImpl(final IStorageDao storageDao) {
        this.storageDao = storageDao;
    }

    @Override
    public void save(Storage storage) {
        storageDao.save(storage);
    }

    @Override
    public Storage findById(Long id) {
        return storageDao.findById(id);
    }

    @Override
    public void decreaseStorage(Order order) {
        storageDao.decreaseStorage(order);
    }

    @Override
    public void decreaseStorageRollback(Order order) {
        storageDao.decreaseStorage(order);
        throw new RuntimeException("测试rollback");
    }
}
